﻿<?xml version="1.0" encoding="utf-8" ?>
<settings defaultOrderBy='MaterialCode'>
  <module>Mms</module>
  <select>*</select>
  <from>
    (select 'receive' as SrcBillType
    ,A.BillNo as SrcBillNo
    ,A.RowId as SrcRowId
    ,B.ReceiveDate as SrcDate
    ,B.WarehouseCode
    ,B.ProjectCode
    ,A.RemainNum
    ,A.UnitPrice as SrcUnitPrice
    ,C.*
    from mms_receiveDetail as A
    left join mms_receive as B ON A.BillNo=B.BillNo
    left join mms_material as C ON A.MaterialCode=C.MaterialCode
    where A.RemainNum>0

    union

    select 'refund' as SrcBillType
    ,A.BillNo as SrcBillNo
    ,A.RowId as SrcRowId
    ,B.RefundDate as SrcDate
    ,B.WarehouseCode
    ,B.ProjectCode
    ,A.RemainNum
    ,A.UnitPrice as SrcUnitPrice
    ,C.*
    from mms_refundDetail as A
    left join mms_refund as B ON A.BillNo=B.BillNo
    left join mms_material as C ON A.MaterialCode=C.MaterialCode
    where A.RemainNum>0

    union

    select 'adjust' as SrcBillType
    ,A.BillNo as SrcBillNo
    ,A.RowId as SrcRowId
    ,B.EffectDate as SrcDate
    ,B.WarehouseCode
    ,B.ProjectCode
    ,A.RemainNum
    ,A.UnitPrice as SrcUnitPrice
    ,C.*
    from mms_stockAdjustDetail as A
    left join mms_stockAdjust as B ON A.BillNo=B.BillNo
    left join mms_material as C ON A.MaterialCode=C.MaterialCode
    where A.RemainNum>0) T
  </from>
  <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
    <field name='MaterialType'      cp='startwith'  ></field>
    <field name='MaterialCode'      cp='startwith'  ></field>
    <field name='MaterialCode'      cp='equal' variable='MaterialCodeEqual'></field>
    <field name='MaterialName'      cp='like'       ></field>
    <field name='ProjectCode'       cp='equal'      ></field>
    <field name='WarehouseCode'     cp='equal' ignoreEmpty='false'></field>
  </where>
</settings>